package senior.DateExer;

import java.text.SimpleDateFormat;
import java.util.Calendar;

/**
 * 学士后结业考试的时间是每月倒数第二个周六上午8点，输出今年的考试时间
 * ，用yyyy/MM/dd hh时 的格式输出
 * @author shkstart
 * @creat 2022-04-19:29
 */
public class Exer6 {
    public static void main(String[] args) {
        Calendar cal = Calendar.getInstance();
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy年MM月dd日 hh:mm E");
        cal.set(Calendar.YEAR,2022);
        cal.set(Calendar.HOUR,8);
        cal.set(Calendar.MINUTE,0);
        int month = cal.getActualMaximum(Calendar.MONTH);
        int day = cal.getActualMaximum(Calendar.DATE);
        for (int i = 0;i <= month;i++){
            cal.set(Calendar.MONTH,i);
            if(i == 1){
                for (int k = 28;k >= 1;k--){
                    cal.set(Calendar.DATE,k);
                    if(cal.get(Calendar.DAY_OF_WEEK) == Calendar.SATURDAY){
                        cal.add(Calendar.DATE,-7);
                        System.out.println(sdf.format(cal.getTime()));
                        break;
                    }
                }
                continue;
            }
            for(int j = day;j >= 1;j--){
                cal.set(Calendar.DATE,j);
                if(cal.get(Calendar.DAY_OF_WEEK) == Calendar.SATURDAY){
                    cal.add(Calendar.DATE,-7);
                    System.out.println(sdf.format(cal.getTime()));
                    break;
                }
            }

        }
    }
}
